<ul class="nav nav-tabs">
    <li role="presentation" class="active"><a href="#">货到付款</a></li>
    <li role="presentation"><a href="javascript:;" onclick="totwoso()">款到发货</a></li>
    <li role="presentation"><a href="javascript:;" onclick="tothreeso()">预付款发货</a></li>
</ul>
<table class="table" id="somainDiv">
    <thead>
    <tr>
        <th>序号</th>
        <th>销售单单编号</th>
        <th>创建时间</th>
        <th>客户名称</th>
        <th>创建用户</th>
        <th>附加费用</th>
        <th>销售商品总价</th>
        <th>销售单总价</th>
        <th>付款方式</th>
        <th>最低预付款金额</th>
        <th>处理状态</th>
        <th colspan="3">操作</th>
    </tr>
    </thead>
    <tbody id="tableBody"></tbody>
</table>
<div>
    <ul id="page">分页</ul>
</div>

<script id="SoFeeFirstTemplate" type="text/html">
    {{each data value index}}
    <tr>
        <td>{{index+1}}</td>
        <td>{{value.soId}}</td>
        <td>{{value.createTime}}</td>
        <td>{{value.customerList[0].name}}</td>
        <td>{{value.scmUserList[0].name}}</td>
        <td>{{value.tipFee}}</td>
        <td>{{value.productTotal}}</td>
        <td>{{value.soTotal}}</td>
        <td>{{value.payType}}</td>
        <td>{{value.prePayFee}}</td>
        <td>{{value.status}}</td>
        <td><input value="了结" type="button"  onclick="settle('{{value.soId}}')"></td>
    </tr>
    {{/each}}
</script>

<script>
    $(function () {
        showPage2({
            payType:"货到付款",
            currentPage: 1,
            pageSize: 5,
            url: '/getAllSomainForSettle',
            templateId: 'SoFeeFirstTemplate',
            contentId: 'tableBody',
            params: {
                id: 1
            }
        })
        Ajax.post(
            "selectAccountByName",
            {
                name:sessionStorage.getItem("name")
            },
            function (result) {
                sessionStorage.setItem("account",result.data[0].account)
            })
    })
    function settle(obj) {
        if(confirm("确认了结此单？")){
            Ajax.post(
                "/settleSomain",
                {soId:obj,
                    endUser:sessionStorage.getItem("account")
                },
                function (result) {
                    show('so/somainSettle.html')
                    alert(result.msg)
                }
            )
        }else{
            show('so/somainSettle.html')
            return false;
        }

    }
</script>
